﻿package mortal.game.scene3D.layer3D.utils
{
    import Message.Public.*;
    import flash.utils.*;
    import mortal.game.scene3D.player.entity.*;

    public class EmbedSceneEntityUtil extends Object
    {
        private var _map:Dictionary;

        public function EmbedSceneEntityUtil()
        {
            this._map = new Dictionary();
            return;
        }// end function

        public function getScene(param1:int) : Dictionary
        {
            var _loc_2:* = this._map[param1] as Dictionary;
            if (_loc_2 == null)
            {
                _loc_2 = new Dictionary();
                this._map[param1] = _loc_2;
            }
            return _loc_2;
        }// end function

        public function addEntity(param1:SEntityId, param2:IEntity, param3:int = 0) : void
        {
            this.getScene(param3)[EntityUtil.toString(param1)] = param2;
            return;
        }// end function

        public function getEntity(param1:SEntityId, param2:int = 0) : IEntity
        {
            return this.getScene(param2)[EntityUtil.toString(param1)];
        }// end function

        public function deleteEntity(param1:SEntityId) : void
        {
            delete this.getScene(param1.msgEx.ex1)[EntityUtil.toString(param1)];
            return;
        }// end function

        public function getEntityMap() : Dictionary
        {
            return this._map;
        }// end function

        public function removeEntity(param1:SEntityId) : void
        {
            var _loc_2:* = this.getEntity(param1, param1.msgEx.ex1) as SpritePlayer;
            if (_loc_2)
            {
                _loc_2.dispose();
                this.deleteEntity(param1);
            }
            return;
        }// end function

        public function removeAll() : void
        {
            var _loc_1:Dictionary = null;
            var _loc_2:* = undefined;
            var _loc_3:SpritePlayer = null;
            for (_loc_2 in this._map)
            {
                
                _loc_1 = this._map[_loc_2];
                for each (_loc_3 in _loc_1)
                {
                    
                    _loc_3.dispose();
                }
                delete this._map[_loc_2];
            }
            this._map = new Dictionary();
            return;
        }// end function

        public function removeEntityBySceneId(param1:int) : void
        {
            var _loc_3:SpritePlayer = null;
            var _loc_2:* = this.getScene(param1);
            for each (_loc_3 in _loc_2)
            {
                
                _loc_3.dispose();
            }
            delete this._map[param1];
            return;
        }// end function

    }
}
